package cn.duxiaod.rabbitmqdemo.mqcallback;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;

/**
 * 消息发送到交换机确认机制
 */
public class MsgSendConfirmCallBack implements RabbitTemplate.ConfirmCallback{
    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        if (ack){
            System.out.println("消息消费成功:"+correlationData.getId());
        }else {
            System.out.println("消息消费失败id："+correlationData.getId()+"，消息："+cause);
        }
    }
}
